package com.test.service;

import com.test.dao.BaseDao;
import com.test.dao.role.RoleDao;
import com.test.dao.role.RoleDaoTmpl;
import com.test.pojo.Role;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class RoleServiceTmpl implements RoleService{

    private RoleDao roleDao;

    public RoleServiceTmpl(){
        roleDao = new RoleDaoTmpl();
    }

    /**
     * 获取角色列表
     * @return Object[] roleList
     */
    public List<Role> getRoleList() {
        Connection connection = null;
        connection = BaseDao.getConnection(); //获得数据库连接
        List<Role> roleList = null;
        try {
            roleList = roleDao.getRoleList(connection);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            //关闭资源
            BaseDao.closeResource(connection,null,null);
        }
        return roleList;
    }
}
